﻿using BrnMall.Manager.Domain.WeChat;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BrnMall.Manager.Manager.WeChat
{
    /// <summary>
    /// 企业微信: SuiteTicket处理
    /// </summary>
    public class SuiteTicketManager
    {
        static string TableName = "wechat_Suiteticket";

        public static void Add(SuiteTicketInfo model)
        {
            using (var db = new QDMallDatabase())
            {
                db.Insert(model);
            }
        }

        /// <summary>
        /// 获取企业微信的的SuiteTicket
        /// </summary>
        /// <returns></returns>
        public static SuiteTicketInfo GetSuiteTicket(int appType)
        {
            using (var db = new QDMallDatabase())
            {
                return db.SingleOrDefault<SuiteTicketInfo>($"select top 1 * from {TableName} where appType={appType} order by id desc");
            }
        }
    }
}